package cn.myweb.interceptor;

import cn.myweb.pojo.User;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import java.util.Map;

public class AuthorizationInterceptor extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        //session
        Map session = actionInvocation.getInvocationContext().getSession();
        User user =(User) session.get("currUser");

        if (user==null){
            return Action.LOGIN;
        }else{
            return  actionInvocation.invoke();
        }
    }
}
